<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--[if IE 7]>
<html id="ie7" dir="ltr" lang="en">
<![endif]-->
<!--[if !(IE 7) ]><!-->
<html dir="ltr" lang="en">
<!--<![endif]-->
<!--
	generated in 1.666 seconds
	64135 bytes batcached for 300 seconds
-->
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Writing a SQL parser &laquo; Codemate</title>
<link rel="stylesheet" href="http://s1.wp.com/wp-content/themes/pub/neutra/style.css?m=1331584635g" type="text/css" media="screen" />
<!--[if lte IE 7]><link href="http://s1.wp.com/wp-content/themes/pub/neutra/css/style-ie.css?m=1268756949g" rel="stylesheet" type="text/css" /><![endif]-->
<link rel="pingback" href="http://codemate.wordpress.com/xmlrpc.php" />
<link rel="alternate" type="application/rss+xml" title="Codemate &raquo; Feed" href="http://codemate.wordpress.com/feed/" />
<link rel="alternate" type="application/rss+xml" title="Codemate &raquo; Comments Feed" href="http://codemate.wordpress.com/comments/feed/" />
<link rel="alternate" type="application/rss+xml" title="Codemate &raquo; Writing a SQL&nbsp;parser Comments Feed" href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/feed/" />
<script type="text/javascript">
/* <![CDATA[ */
function addLoadEvent(func){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func;}else{window.onload=function(){oldonload();func();}}}
/* ]]> */
</script>
<link rel="stylesheet" href="http://s0.wp.com/wp-content/themes/h4/global.css?m=1313010094g" type="text/css" />
<link rel='stylesheet' id='loggedout-subscribe-css'  href='http://s1.wp.com/wp-content/blog-plugins/loggedout-follow/widget.css?m=1330044119g&#038;ver=20120104' type='text/css' media='all' />
<link rel='stylesheet' id='post-reactions-css'  href='http://s1.wp.com/wp-content/mu-plugins/post-flair/style.css?m=1335512048g&#038;ver=4' type='text/css' media='all' />
<link rel='stylesheet' id='a8c-global-print-css'  href='http://s2.wp.com/wp-content/mu-plugins/global-print/global-print.css?m=1335386953g&#038;ver=20120418' type='text/css' media='print' />
<script type='text/javascript' src='http://s0.wp.com/wp-includes/js/jquery/jquery.js?m=1333391137g&#038;ver=1.7.2'></script>
<script type='text/javascript'>
/* <![CDATA[ */
var LoggedOutFollow = {"invalid_email":"Your subscription did not succeed, please try again with a valid email address."};
/* ]]> */
</script>
<script type='text/javascript' src='http://s1.wp.com/wp-content/blog-plugins/loggedout-follow/widget.js?m=1329327657g&#038;ver=20120215'></script>
<script type='text/javascript' src='http://s1.wp.com/wp-includes/js/comment-reply.js?m=1231878779g&#038;ver=3.4-beta4-20792'></script>
<link rel='stylesheet' id='highlander-comments-css'  href='http://s0.wp.com/wp-content/mu-plugins/highlander-comments/style.css?m=1334188075g&#038;ver=20110620' type='text/css' media='all' />
<!--[if lt IE 8]>
<link rel='stylesheet' id='highlander-comments-ie7-css'  href='http://s0.wp.com/wp-content/mu-plugins/highlander-comments/style-ie7.css?m=1307172283g&#038;ver=20110606' type='text/css' media='all' />
<![endif]-->
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://codemate.wordpress.com/xmlrpc.php?rsd" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://codemate.wordpress.com/wp-includes/wlwmanifest.xml" /> 
<link rel='prev' title='Emacs tip: bulk operations on&nbsp;buffers' href='http://codemate.wordpress.com/2009/01/16/emacs-tip-bulk-operations-on-buffers/' />
<link rel='next' title='Moving Editor Configuration into the&nbsp;Cloud' href='http://codemate.wordpress.com/2009/03/20/moving-editor-configuration-into-the-cloud/' />
<meta name="generator" content="WordPress.com" />
<link rel='canonical' href='http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/' />
<link rel='shortlink' href='http://wp.me/p20at-4t' />
<link rel="alternate" type="application/json+oembed" href="http://public-api.wordpress.com/oembed/1.0/?format=json&amp;url=http%3A%2F%2Fcodemate.wordpress.com%2F2009%2F02%2F06%2Fwriting-a-sql-parser%2F&amp;for=wpcom-auto-discovery" /><link rel="alternate" type="application/xml+oembed" href="http://public-api.wordpress.com/oembed/1.0/?format=xml&amp;url=http%3A%2F%2Fcodemate.wordpress.com%2F2009%2F02%2F06%2Fwriting-a-sql-parser%2F&amp;for=wpcom-auto-discovery" /><meta property="og:type" content="article" />
<meta property="og:title" content="Writing a SQL&nbsp;parser" />
<meta property="og:url" content="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/" />
<meta property="og:description" content="Well&#8230; not exactly writing a parser but generating one. For the task I&#8217;ve been working on recently I needed to have (inside my java code) a data model representing database tables, so I ..." />
<meta property="og:site_name" content="Codemate" />
<link rel="shortcut icon" type="image/x-icon" href="http://s2.wp.com/i/favicon.ico?m=1311976023g" sizes="16x16 24x24 32x32 48x48" />
<link rel="icon" type="image/x-icon" href="http://s2.wp.com/i/favicon.ico?m=1311976023g" sizes="16x16 24x24 32x32 48x48" />
<link rel="apple-touch-icon-precomposed" href="http://s0.wp.com/i/webclip.png?m=1311618091g" />
<link rel='openid.server' href='http://codemate.wordpress.com/?openidserver=1' />
<link rel='openid.delegate' href='http://codemate.wordpress.com/' />
<link rel="search" type="application/opensearchdescription+xml" href="http://codemate.wordpress.com/osd.xml" title="Codemate" />
<link rel="search" type="application/opensearchdescription+xml" href="http://wordpress.com/opensearch.xml" title="WordPress.com" />
<meta name="application-name" content="Codemate" /><meta name="msapplication-window" content="width=device-width;height=device-height" /><meta name="msapplication-tooltip" content="Being friends with the code" /><meta name="msapplication-task" content="name=Subscribe;action-uri=http://codemate.wordpress.com/feed/;icon-uri=http://s2.wp.com/i/favicon.ico" /><meta name="msapplication-task" content="name=Sign up for a free blog;action-uri=http://wordpress.com/signup/;icon-uri=http://s2.wp.com/i/favicon.ico" /><meta name="msapplication-task" content="name=WordPress.com Support;action-uri=http://support.wordpress.com/;icon-uri=http://s2.wp.com/i/favicon.ico" /><meta name="msapplication-task" content="name=WordPress.com Forums;action-uri=http://forums.wordpress.com/;icon-uri=http://s2.wp.com/i/favicon.ico" /></head>
<body class="single single-post postid-277 single-format-standard highlander-enabled highlander-light">
<div id="container">
<div id="header">
	<h1><a href="http://codemate.wordpress.com/" title="Codemate">Codemate</a></h1>
	<p>Being friends with the code</p>

	<div id="menu">
			<ul>
		<li class="page_item page-item-9"><a href="http://codemate.wordpress.com/about_us/">About&nbsp;us</a></li>
	</ul>
	</div>

	<div id="search">
		<form method="get" id="searchform" action="http://codemate.wordpress.com/">
	<p><input type="text" size="12" value="Search this Blog" name="s" id="s" class="ipt-keywords" onfocus="if (this.value == this.defaultValue) this.value = ''" /></p>
</form>	</div>
</div><!-- /header -->
<div id="page">

	<div id="left">

							<div class="post-277 post type-post status-publish format-standard hentry category-development category-java category-software-development category-uncategorized tag-antlr tag-grammar tag-java tag-javacc tag-parser tag-parsing tag-sql post" id="post-277">
				<h2 class="title">Writing a SQL&nbsp;parser</h2>
				<div class="postcontent">
					<p>Well&#8230; not exactly writing a parser but generating one.<br />
For the task I&#8217;ve been working on recently I needed to have (inside my java code) a data model representing database tables, so I could perform data normalization according to it.</p>
<p><em>&#8220;CREATE TABLE&#8221;</em> sql statement is a natural fit for representing the data model. The only thing I had to decide on is parser. How do I parse SQL? Can I use something off-the-shelf? I asked myself and it turns out yes I can!<br />
I took a look at <a href="https://javacc.dev.java.net/">Javacc</a> and then at <a href="http://www.antlr.org/">Antlr</a>. Antlr seemed more, I would say, mature, more documentation, tutorials, sample grammars, etc. </p>
<p>Antlr (ANother Tool for Language Recognition) </p>
<blockquote><p>
is a language tool that provides a framework for constructing recognizers, compilers, and translators from grammatical descriptions containing actions in a variety of target languages.
</p></blockquote>
<p>BTW, the data I was going to parse looked like this:<br />
<pre class="brush: sql;">
CREATE TABLE table_one (
    customer_number integer NOT NULL,
    address character varying(30)
);

CREATE TABLE table_two (
    id integer NOT NULL,
    city character varying(50)
);
</pre></p>
<p>I wrote following grammar for it:<br />
<pre class="brush: java;">
grammar CreateTable;

/*------------------------------------------------------------------
 * PARSER RULES
 *------------------------------------------------------------------*/

table_list :
    (table_def)*;

table_def :
    'create' 'table' table_name table_element_list SEMICOLON;

table_name :
    (schema DOT)? table;

table_element_list :
    LEFT_PAREN table_element (COMMA table_element)* RIGHT_PAREN;

table_element :
    column_name data_type_def (column_constraint)?;

data_type_def :
    data_type lenght_constraint?;

schema : ID;

table : ID;

column_name :ID;

data_type : ID:

length_constraint :
    LEFT_PAREN NUMBER RIGHT_PAREN;

/*------------------------------------------------------------------
 * LEXER RULES
 *------------------------------------------------------------------*/

LEFT_PAREN : '(';
RIGHT_PAREN : ')';
COMMA : ',';
SEMICOLON : ';';
DOT	:	 '.';
NUMBER 	:	(DIGIT)+;	
ID  : (('a'..'z'|'A'..'Z' | '_') ((DIGIT)*))+ ;
NEWLINE:'\r'? '\n' ;
WS : ( '\t' | ' ' | '\r' | '\n' | '\u000C' )+ 	{ $channel = HIDDEN; } ;
fragment DIGIT :   '0'..'9' ;
</pre></p>
<p>This is all fine but I want my parser to return data right away like:</p>
<p><pre class="brush: java;">
List&lt;Table&gt; tables = parser.table_list();
List&lt;Column&gt; cols = table.getColumns();
Column col = table.getColumn(&quot;id&quot;);
col.getName();
col.getType();
col.getConstriant();
col.getLength();
</pre></p>
<p>So we have to made a few changes to our parser rules in the grammar.</p>
<p><pre class="brush: java;">
grammar CreateTable;

@header {
import java.util.ArrayList;
import java.util.List;

}

table_list returns [List tables] 
	: {$tables = new ArrayList();}	(table_def { $tables.add($table_def.tbl); } )*  ;
	

table_def returns [Table tbl]
	: 'create' 'table' table_name 
		table_element_list {
			$tbl = new Table(String.valueOf($table_name.text), $table_element_list.cols);
		}
		SEMICOLON ;

table_name 
	:	(schema DOT)? table  ;

table_element_list returns [List cols]
	: {$cols = new ArrayList();} LEFT_PAREN te=table_element {$cols.add($te.col);} (COMMA te=table_element {$cols.add($te.col);})*   RIGHT_PAREN ;

table_element returns [Column col]
	:  column_name data_type_def (column_constraint)? {$col = new Column($column_name.cn, $data_type_def.tpe, $column_constraint.text, $data_type_def.len);};

column_name returns [String cn]
	:	ID {$cn = String.valueOf($ID.text); };

column_constraint
	:	'not' 'null';

data_type_def returns [String tpe, Integer len]
	: data_type {$tpe = $data_type.tp;} length_constraint? {$len = $length_constraint.len;} 	 
	;
	
data_type returns [String tp]
	: 
	((('character' 'varying')  | 'varchar') {$tp = &quot;varchar&quot;;}
		| ('bit' 'varying' | 'varbit') {$tp = &quot;varbit&quot;;}
		| ('double' 'precision' | 'float8') {$tp = &quot;float8&quot;; }
		| ('character' | 'char') {$tp = &quot;char&quot;;}
		| ('integer' | 'int' | 'int4') {$tp = &quot;integer&quot;;}
		| ID {$tp = $ID.text;}
		);
	

length_constraint returns [Integer len] 
	: LEFT_PAREN NUMBER RIGHT_PAREN {$len = Integer.valueOf($NUMBER.text);} 	;
	
schema : ID;
table :	ID;

/*------------------------------------------------------------------
 * LEXER RULES
 *------------------------------------------------------------------*/

LEFT_PAREN : '(';
RIGHT_PAREN : ')';
COMMA : ',';
SEMICOLON : ';';
DOT	:	 '.';
NUMBER 	:	(DIGIT)+;	
ID  : (('a'..'z'|'A'..'Z' | '_') ((DIGIT)*))+ ;
NEWLINE:'\r'? '\n' ;
WS : ( '\t' | ' ' | '\r' | '\n' | '\u000C' )+ 	{ $channel = HIDDEN; } ;
fragment DIGIT :   '0'..'9' ;

</pre></p>
<p>That&#8217;s basically it. I have a parser that I wanted and I think it took me less than I would have spent writing my own.<br />
There are many <a href="http://www.antlr.org/grammar/list">sample grammars</a>. Have a look maybe there is existing one for the language you&#8217;re about to parse. :) </p>
<p>P.S. The exact &#8220;CREATE TABLE&#8221; SQL statement is slightly more complex that I assume in the grammar.</p>
<div id="jp-post-flair" class="sharedaddy sd-like-enabled"><div class="wpl-likebox sd-block sd-like"><h3 class="sd-title">Like this:</h3><div class="sd-content"><div id="like-277" class="wpl-button "><a href='http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/?like=1&amp;_wpnonce=57af6df0a3' title='I like this post' class='like needs-login sd-button' rel='nofollow'><span>Like</span></a></div><div class="wpl-count sd-like-count">Be the first to like this post.</div></div></div></div>										<p class="edit-post"></p>

					<div class="postmetadata">
						<div class="floatleft">
							<p><span class="category"><a href="http://codemate.wordpress.com/category/development/" title="View all posts in Development" rel="category tag">Development</a>, <a href="http://codemate.wordpress.com/category/java/" title="View all posts in Java" rel="category tag">Java</a>, <a href="http://codemate.wordpress.com/category/software-development/" title="View all posts in Software development" rel="category tag">Software development</a>, <a href="http://codemate.wordpress.com/category/uncategorized/" title="View all posts in Uncategorized" rel="category tag">Uncategorized</a></span></p>
							<p><span class="tags"><a href="http://codemate.wordpress.com/tag/antlr/" rel="tag">antlr</a>, <a href="http://codemate.wordpress.com/tag/grammar/" rel="tag">grammar</a>, <a href="http://codemate.wordpress.com/tag/java/" rel="tag">Java</a>, <a href="http://codemate.wordpress.com/tag/javacc/" rel="tag">javacc</a>, <a href="http://codemate.wordpress.com/tag/parser/" rel="tag">parser</a>, <a href="http://codemate.wordpress.com/tag/parsing/" rel="tag">parsing</a>, <a href="http://codemate.wordpress.com/tag/sql/" rel="tag">sql</a></span></p>
						</div><!-- /floatleft -->
						<div class="floatright">
							<p><span class="date">February 6, 2009</span></p>
							<p><span class="comments"><a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/#comments" title="Comment on Writing a SQL&nbsp;parser">13 Comments</a></span></p>
						</div><!-- /floatright -->
					</div><!-- /postmetadata -->

				</div><!-- /postcontent -->
			</div><!-- /post -->

			<div class="navigation">
				<div class="alignleft"><a href="http://codemate.wordpress.com/2009/01/16/emacs-tip-bulk-operations-on-buffers/" rel="prev">&laquo; Emacs tip: bulk operations on&nbsp;buffers</a></div>
				<div class="alignright"><a href="http://codemate.wordpress.com/2009/03/20/moving-editor-configuration-into-the-cloud/" rel="next">Moving Editor Configuration into the&nbsp;Cloud &raquo;</a></div>
			</div><!-- /navigation -->

			<div id="comment-template">


	
		<h2><span>13 comments</span></h2>
		<p class="do-you-comment"><a href="#respond" title="Comment">Do you want to comment?</a></p>
		<p class="trackback">
			<a href='http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/feed/'>Comments RSS</a>			and <a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/trackback/" rel="trackback">TrackBack URI</a>		</p><!-- /trackback -->

		<ol id="commentlist">
				<li class="comment byuser comment-author-michaelnaganoff even thread-even depth-1 highlander-comment" id="comment-4373">
		<div class="comment-avatar">
			<div class="avatar-wrap"><img alt='' src='http://1.gravatar.com/avatar/9c8f6a36ad787da54bb9e99195e1fab8?s=80&amp;d=identicon&amp;r=G' class='avatar avatar-80' height='80' width='80' /></div><!-- /avatar -->
		</div>
		<div class="comment-body">
			<div class="author"><a href='http://nmv.tiddlyspot.com' rel='external nofollow' class='url'>Mikhail Naganov</a></div>
			<div class="comment-text"><p>I&#8217;m puzzled with your &#8216;ID&#8217; specification. Shouldn&#8217;t it be like the one below?</p>
<p>&#8216;a&#8217; .. &#8216;z&#8217; ( &#8216;a&#8217; .. &#8216;z&#8217; | &#8217;0&#8242; .. &#8217;9&#8242; | &#8216;_&#8217; )*</p>
</div>
			<div class="comment-meta"><a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/#comment-4373">Permalink</a>, <a class='comment-reply-link' href='/2009/02/06/writing-a-sql-parser/?replytocom=4373#respond' onclick='return addComment.moveForm("comment-4373", "4373", "respond", "277")'>Reply</a></div>
			<div class="date"><span>February 6, 2009 <a href="#comment-4373">11:50 pm</a></span></div>
		</div>
</li>
	<li class="comment byuser comment-author-dglinenko bypostauthor odd alt thread-odd thread-alt depth-1 highlander-comment" id="comment-4374">
		<div class="comment-avatar">
			<div class="avatar-wrap"><img alt='' src='http://1.gravatar.com/avatar/f927bbed86e344d3d97ed4d5f6a926c9?s=80&amp;d=identicon&amp;r=G' class='avatar avatar-80' height='80' width='80' /></div><!-- /avatar -->
		</div>
		<div class="comment-body">
			<div class="author"><a href='http://codemate.wordpress.com/' rel='external nofollow' class='url'>Danil Glinenko</a></div>
			<div class="comment-text"><p>Um&#8230; ID can start with &#8220;_&#8221; symbol so it probably should look like<br />
ID	:	 (&#8216;a&#8217;.. &#8216;z&#8217; | &#8216;_&#8217;) (&#8216;a&#8217;..&#8217;z&#8217; | &#8217;0&#8242;..&#8217;9&#8242; | &#8216;_&#8217; )*;</p>
</div>
			<div class="comment-meta"><a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/#comment-4374">Permalink</a>, <a class='comment-reply-link' href='/2009/02/06/writing-a-sql-parser/?replytocom=4374#respond' onclick='return addComment.moveForm("comment-4374", "4374", "respond", "277")'>Reply</a></div>
			<div class="date"><span>February 7, 2009 <a href="#comment-4374">7:59 am</a></span></div>
		</div>
</li>
	<li class="comment even thread-even depth-1 highlander-comment" id="comment-4384">
		<div class="comment-avatar">
			<div class="avatar-wrap"><img alt='' src='http://0.gravatar.com/avatar/ea0662af98f5642193079ebbb7e78fd5?s=80&amp;d=identicon&amp;r=G' class='avatar avatar-80' height='80' width='80' /></div><!-- /avatar -->
		</div>
		<div class="comment-body">
			<div class="author">dzieciou</div>
			<div class="comment-text"><p>&#8220;The exact “CREATE TABLE” SQL statement is slightly more complex that I assume in the grammar&#8221;&#8211; slightly? ;-)</p>
<p>I think much more complex. I was looking on ANTLR grammars list for some SQL&#8217;92 grammar but unforunately there is nothing like this. I wonder why?</p>
<p>I&#8217;ve started to manually create it translating from BNF definitions but it looks like a tedious task. Do you now any complete ANTLR grammar for SQL?</p>
<p>Best,<br />
Maciej</p>
</div>
			<div class="comment-meta"><a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/#comment-4384">Permalink</a>, <a class='comment-reply-link' href='/2009/02/06/writing-a-sql-parser/?replytocom=4384#respond' onclick='return addComment.moveForm("comment-4384", "4384", "respond", "277")'>Reply</a></div>
			<div class="date"><span>March 9, 2009 <a href="#comment-4384">8:41 pm</a></span></div>
		</div>
</li>
	<li class="comment byuser comment-author-dglinenko bypostauthor odd alt thread-odd thread-alt depth-1 highlander-comment" id="comment-4385">
		<div class="comment-avatar">
			<div class="avatar-wrap"><img alt='' src='http://1.gravatar.com/avatar/f927bbed86e344d3d97ed4d5f6a926c9?s=80&amp;d=identicon&amp;r=G' class='avatar avatar-80' height='80' width='80' /></div><!-- /avatar -->
		</div>
		<div class="comment-body">
			<div class="author"><a href='http://codemate.wordpress.com/' rel='external nofollow' class='url'>Danil Glinenko</a></div>
			<div class="comment-text"><p>The &#8220;create table&#8221; only statement is not too complex, but the entire ANSI standard SQL grammar is. Anyway, have a look at the following links:<br />
<a href="http://www.antlr.org/grammar/1057936474293/index.html" rel="nofollow">http://www.antlr.org/grammar/1057936474293/index.html</a><br />
<a href="http://www.antlr.org/grammar/1057863397080/index.html" rel="nofollow">http://www.antlr.org/grammar/1057863397080/index.html</a></p>
<p>Hope this helps.</p>
</div>
			<div class="comment-meta"><a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/#comment-4385">Permalink</a>, <a class='comment-reply-link' href='/2009/02/06/writing-a-sql-parser/?replytocom=4385#respond' onclick='return addComment.moveForm("comment-4385", "4385", "respond", "277")'>Reply</a></div>
			<div class="date"><span>March 9, 2009 <a href="#comment-4385">9:27 pm</a></span></div>
		</div>
</li>
	<li class="comment even thread-even depth-1 highlander-comment" id="comment-4386">
		<div class="comment-avatar">
			<div class="avatar-wrap"><img alt='' src='http://0.gravatar.com/avatar/ea0662af98f5642193079ebbb7e78fd5?s=80&amp;d=identicon&amp;r=G' class='avatar avatar-80' height='80' width='80' /></div><!-- /avatar -->
		</div>
		<div class="comment-body">
			<div class="author">dzieciou</div>
			<div class="comment-text"><p>Danil,<br />
Thanks for grammars links. However, they are in ANTLR v2 which is quite different from the current V3, supported by ANTLRWorks IDE. Conversion it is also not so straightforward for me (this is compositional grammar combining parser and lexer together and need to be separater first). Do you have v3 version of it?</p>
</div>
			<div class="comment-meta"><a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/#comment-4386">Permalink</a>, <a class='comment-reply-link' href='/2009/02/06/writing-a-sql-parser/?replytocom=4386#respond' onclick='return addComment.moveForm("comment-4386", "4386", "respond", "277")'>Reply</a></div>
			<div class="date"><span>March 10, 2009 <a href="#comment-4386">12:36 pm</a></span></div>
		</div>
</li>
	<li class="comment byuser comment-author-dglinenko bypostauthor odd alt thread-odd thread-alt depth-1 highlander-comment" id="comment-4387">
		<div class="comment-avatar">
			<div class="avatar-wrap"><img alt='' src='http://1.gravatar.com/avatar/f927bbed86e344d3d97ed4d5f6a926c9?s=80&amp;d=identicon&amp;r=G' class='avatar avatar-80' height='80' width='80' /></div><!-- /avatar -->
		</div>
		<div class="comment-body">
			<div class="author"><a href='http://codemate.wordpress.com/' rel='external nofollow' class='url'>Danil Glinenko</a></div>
			<div class="comment-text"><p>I don&#8217;t have it. :( So you&#8217;ll probably have to translate it by yourself. Also I&#8217;m sure you&#8217;ve seen it but just in case <a href="http://savage.net.au/SQL/sql-92.bnf.html" rel="nofollow">http://savage.net.au/SQL/sql-92.bnf.html</a></p>
</div>
			<div class="comment-meta"><a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/#comment-4387">Permalink</a>, <a class='comment-reply-link' href='/2009/02/06/writing-a-sql-parser/?replytocom=4387#respond' onclick='return addComment.moveForm("comment-4387", "4387", "respond", "277")'>Reply</a></div>
			<div class="date"><span>March 10, 2009 <a href="#comment-4387">8:09 pm</a></span></div>
		</div>
</li>
	<li class="comment even thread-even depth-1 highlander-comment" id="comment-4398">
		<div class="comment-avatar">
			<div class="avatar-wrap"><img alt='' src='http://0.gravatar.com/avatar/61cf72aee608a6971a5cea5cb8332185?s=80&amp;d=identicon&amp;r=G' class='avatar avatar-80' height='80' width='80' /></div><!-- /avatar -->
		</div>
		<div class="comment-body">
			<div class="author">jason henriksen</div>
			<div class="comment-text"><p>When I generate your grammer I get code that fails because Table and Column are not defined classes. </p>
<p>Is ANTLR supposed to be generating those, or am I supposed to have coded them myself?  What should they look like?</p>
<p>Thanks!</p>
</div>
			<div class="comment-meta"><a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/#comment-4398">Permalink</a>, <a class='comment-reply-link' href='/2009/02/06/writing-a-sql-parser/?replytocom=4398#respond' onclick='return addComment.moveForm("comment-4398", "4398", "respond", "277")'>Reply</a></div>
			<div class="date"><span>April 12, 2009 <a href="#comment-4398">2:27 am</a></span></div>
		</div>
</li>
	<li class="comment odd alt thread-odd thread-alt depth-1 highlander-comment" id="comment-4399">
		<div class="comment-avatar">
			<div class="avatar-wrap"><img alt='' src='http://1.gravatar.com/avatar/f927bbed86e344d3d97ed4d5f6a926c9?s=80&amp;d=identicon&amp;r=G' class='avatar avatar-80' height='80' width='80' /></div><!-- /avatar -->
		</div>
		<div class="comment-body">
			<div class="author">Danil Glinenko</div>
			<div class="comment-text"><p>Yes, you&#8217;re supposed to create them. They are very simple though. Just java beans. </p>
<pre class="brush: java;">
public class Column implements Comparable {
    private String name;
    private String dataType;
    private String constraint;
    private Integer length;

    public Column(final String name, final String dataType, final String constraint, final Integer len) {
        this.name = name;
        this.dataType = dataType;
        this.constraint = constraint;
        this.length = len;
    }
// setters, getters go here


public class Table {
    private String name;
    private List&lt;Column&gt; columns;

    public Table(final String name, List&lt;Column&gt; cols) {
        this.name = name;
        Collections.sort(cols);
        this.columns = cols;
    }
// getters, setters go here.


</pre>
</div>
			<div class="comment-meta"><a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/#comment-4399">Permalink</a>, <a class='comment-reply-link' href='/2009/02/06/writing-a-sql-parser/?replytocom=4399#respond' onclick='return addComment.moveForm("comment-4399", "4399", "respond", "277")'>Reply</a></div>
			<div class="date"><span>April 14, 2009 <a href="#comment-4399">9:29 am</a></span></div>
		</div>
</li>
	<li class="comment even thread-even depth-1 highlander-comment" id="comment-4414">
		<div class="comment-avatar">
			<div class="avatar-wrap"><img alt='' src='http://1.gravatar.com/avatar/9b0d8c2175534099cf4f31bcff0106f7?s=80&amp;d=identicon&amp;r=G' class='avatar avatar-80' height='80' width='80' /></div><!-- /avatar -->
		</div>
		<div class="comment-body">
			<div class="author"><a href='http://www.dataalp.com' rel='external nofollow' class='url'>Vijay A</a></div>
			<div class="comment-text"><p>Using the Derby Parser could be an alternative to folks who want SQL parsing abilities in their applications.</p>
<p><a href="http://issues.apache.org/jira/browse/DERBY-3946" rel="nofollow">http://issues.apache.org/jira/browse/DERBY-3946</a></p>
</div>
			<div class="comment-meta"><a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/#comment-4414">Permalink</a>, <a class='comment-reply-link' href='/2009/02/06/writing-a-sql-parser/?replytocom=4414#respond' onclick='return addComment.moveForm("comment-4414", "4414", "respond", "277")'>Reply</a></div>
			<div class="date"><span>June 1, 2009 <a href="#comment-4414">10:50 pm</a></span></div>
		</div>
<ul class='children'>
	<li class="comment odd alt depth-2 highlander-comment" id="comment-4415">
		<div class="comment-avatar">
			<div class="avatar-wrap"><img alt='' src='http://1.gravatar.com/avatar/f927bbed86e344d3d97ed4d5f6a926c9?s=80&amp;d=identicon&amp;r=G' class='avatar avatar-80' height='80' width='80' /></div><!-- /avatar -->
		</div>
		<div class="comment-body">
			<div class="author"><a href='http://codemate.wordpress.com' rel='external nofollow' class='url'>Danil Glinenko</a></div>
			<div class="comment-text"><p>Thanks for the link. I didn&#8217;t consider such alternatives.</p>
</div>
			<div class="comment-meta"><a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/#comment-4415">Permalink</a>, <a class='comment-reply-link' href='/2009/02/06/writing-a-sql-parser/?replytocom=4415#respond' onclick='return addComment.moveForm("comment-4415", "4415", "respond", "277")'>Reply</a></div>
			<div class="date"><span>June 2, 2009 <a href="#comment-4415">12:48 am</a></span></div>
		</div>
<ul class='children'>
	<li class="comment even depth-3 highlander-comment" id="comment-4449">
		<div class="comment-avatar">
			<div class="avatar-wrap"><img alt='' src='http://1.gravatar.com/avatar/d3d1e4aa79ac680843ba722123558748?s=80&amp;d=identicon&amp;r=G' class='avatar avatar-80' height='80' width='80' /></div><!-- /avatar -->
		</div>
		<div class="comment-body">
			<div class="author">Elango Muthu</div>
			<div class="comment-text"><p>Finally what you had finalized with? Your own grammar based on ANTLR or other alternative like Derby?</p>
</div>
			<div class="comment-meta"><a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/#comment-4449">Permalink</a></div>
			<div class="date"><span>May 18, 2010 <a href="#comment-4449">12:29 pm</a></span></div>
		</div>
</li>
</ul>
</li>
</ul>
</li>
	<li class="comment byuser comment-author-dglinenko bypostauthor odd alt thread-odd thread-alt depth-1 highlander-comment" id="comment-4450">
		<div class="comment-avatar">
			<div class="avatar-wrap"><img alt='' src='http://1.gravatar.com/avatar/f927bbed86e344d3d97ed4d5f6a926c9?s=80&amp;d=identicon&amp;r=G' class='avatar avatar-80' height='80' width='80' /></div><!-- /avatar -->
		</div>
		<div class="comment-body">
			<div class="author"><a href='http://codemate.wordpress.com/' rel='external nofollow' class='url'>Danil Glinenko</a></div>
			<div class="comment-text"><p>ANTLR grammar from this post. At the time of writing I&#8217;d had this grammar already integrated into the application and it worked well.</p>
</div>
			<div class="comment-meta"><a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/#comment-4450">Permalink</a>, <a class='comment-reply-link' href='/2009/02/06/writing-a-sql-parser/?replytocom=4450#respond' onclick='return addComment.moveForm("comment-4450", "4450", "respond", "277")'>Reply</a></div>
			<div class="date"><span>May 18, 2010 <a href="#comment-4450">8:22 pm</a></span></div>
		</div>
</li>
	<li class="comment even thread-even depth-1 highlander-comment" id="comment-4476">
		<div class="comment-avatar">
			<div class="avatar-wrap"><img alt='' src='http://1.gravatar.com/avatar/d1f1b733c6a24d56606e7ac535e27545?s=80&amp;d=identicon&amp;r=G' class='avatar avatar-80' height='80' width='80' /></div><!-- /avatar -->
		</div>
		<div class="comment-body">
			<div class="author">kiquenet</div>
			<div class="comment-text"><p>Hi mister, </p>
<p>I want create SQL Parser (Oracle), and get tables and columns like your sample:</p>
<p> List tables = parser.table_list();<br />
 List cols = table.getColumns();  </p>
<p>Can I download your code (*.g file, etc) ??</p>
<p>Thanks.</p>
</div>
			<div class="comment-meta"><a href="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/#comment-4476">Permalink</a>, <a class='comment-reply-link' href='/2009/02/06/writing-a-sql-parser/?replytocom=4476#respond' onclick='return addComment.moveForm("comment-4476", "4476", "respond", "277")'>Reply</a></div>
			<div class="date"><span>August 30, 2010 <a href="#comment-4476">4:04 pm</a></span></div>
		</div>
</li>
		</ol>

		<div class="navigation">
			<div class="alignleft"></div>
			<div class="alignright"></div>
		</div>

	
	
										<div id="respond">
				<h3 id="reply-title"><span>Leave a Reply</span> <small><a rel="nofollow" id="cancel-comment-reply-link" href="/2009/02/06/writing-a-sql-parser/#respond" style="display:none;">Cancel reply</a></small></h3>
									<form action="http://codemate.wordpress.com/wp-comments-post.php" method="post" id="commentform">
																										


												
<input type="hidden" name="hc_post_as" id="hc_post_as" value="guest" />

<div class="comment-form-field comment-textarea">
	<label for="comment">Enter your comment here...</label>
	<div id="comment-form-comment"><textarea id="comment" name="comment"></textarea></div>
</div>

<div id="comment-form-identity">

	<div id="comment-form-nascar">
		<p>Fill in your details below or click an icon to log in:</p>
		<ul>
			<li class="selected" style="display:none;">
				<a href="#comment-form-guest" id="postas-guest" title="Guest">
					<span></span>
				</a>
			</li>
			<li>
				<a href="#comment-form-load-service:WordPress.com" id="postas-wordpress" title="WordPress.com">
					<span></span>
				</a>
			</li>
			<li>
				<a href="#comment-form-load-service:Twitter" id="postas-twitter" title="Twitter">
					<span></span>
				</a>
			</li>
			<li>
				<a href="#comment-form-load-service:Facebook" id="postas-facebook" title="Facebook">
					<span></span>
				</a>
			</li>
		</ul>
	</div>

	<div id="comment-form-guest" class="comment-form-service selected">
		<div class="comment-form-padder">
			<div class="comment-form-avatar">
<a href="https://gravatar.com/site/signup/" target="_blank">				<img src="http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25&forcedefault=1&d=identicon" alt="Gravatar" width="25" class="no-grav" />
</a>			</div>

				<div class="comment-form-fields">
				<div class="comment-form-field comment-form-email">
					<label for="email">Email <span class="required">(required)</span> <span class="nopublish">(Address never made public)</span></label>
					<div class="comment-form-input"><input id="email" name="email" type="text" value="" /></div>
				</div>
				<div class="comment-form-field comment-form-author">
					<label for="author">Name <span class="required">(required)</span></label>
					<div class="comment-form-input"><input id="author" name="author" type="text" value="" /></div>
				</div>
				<div class="comment-form-field comment-form-url">
					<label for="url">Website</label>
					<div class="comment-form-input"><input id="url" name="url" type="text" value="" /></div>
				</div> 
			</div>
	
		</div>
	</div>

	<div id="comment-form-wordpress" class="comment-form-service">
		<div class="comment-form-padder">
			<div class="comment-form-avatar">
				<img src="http://s2.wp.com/wp-content/mu-plugins/highlander-comments/images/wplogo.png?m=1289230950g" alt="WordPress.com Logo" width="25" class="no-grav" />
			</div>

				<div class="comment-form-fields">
				<input type="hidden" name="wp_avatar" id="wordpress-avatar" class="comment-meta-wordpress" value="" />
				<input type="hidden" name="wp_user_id" id="wordpress-user_id" class="comment-meta-wordpress" value="" />
				<input type="hidden" name="wp_access_token" id="wordpress-access_token" class="comment-meta-wordpress" value="" />
				<p class="comment-form-posting-as pa-wordpress"><strong></strong> You are commenting using your WordPress.com account. <span class="comment-form-log-out">(&nbsp;<a href="javascript:HighlanderComments.doExternalLogout( 'wordpress' );">Log&nbsp;Out</a>&nbsp;/&nbsp;<a href="#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a>&nbsp;)</span></p>
			</div>
	
		</div>
	</div>

	<div id="comment-form-twitter" class="comment-form-service">
		<div class="comment-form-padder">
			<div class="comment-form-avatar">
				<img src="http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25&d=identicon" alt="Twitter picture" width="25" class="no-grav" />
			</div>

				<div class="comment-form-fields">
				<input type="hidden" name="twitter_avatar" id="twitter-avatar" class="comment-meta-twitter" value="" />
				<input type="hidden" name="twitter_user_id" id="twitter-user_id" class="comment-meta-twitter" value="" />
				<input type="hidden" name="twitter_access_token" id="twitter-access_token" class="comment-meta-twitter" value="" />
				<p class="comment-form-posting-as pa-twitter"><strong></strong> You are commenting using your Twitter account. <span class="comment-form-log-out">(&nbsp;<a href="javascript:HighlanderComments.doExternalLogout( 'twitter' );">Log&nbsp;Out</a>&nbsp;/&nbsp;<a href="#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a>&nbsp;)</span></p>
			</div>
	
		</div>
	</div>

	<div id="comment-form-facebook" class="comment-form-service">
		<div class="comment-form-padder">
			<div class="comment-form-avatar">
				<img src="http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25&d=identicon" alt="Facebook photo" width="25" class="no-grav" />
			</div>

				<div class="comment-form-fields">
				<input type="hidden" name="fb_avatar" id="facebook-avatar" class="comment-meta-facebook" value="" />
				<input type="hidden" name="fb_user_id" id="facebook-user_id" class="comment-meta-facebook" value="" />
				<input type="hidden" name="fb_access_token" id="facebook-access_token" class="comment-meta-facebook" value="" />
				<p class="comment-form-posting-as pa-facebook"><strong></strong> You are commenting using your Facebook account. <span class="comment-form-log-out">(&nbsp;<a href="javascript:HighlanderComments.doExternalLogout( 'facebook' );">Log&nbsp;Out</a>&nbsp;/&nbsp;<a href="#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a>&nbsp;)</span></p>
			</div>
	
		</div>
	</div>


	<div id="comment-form-load-service" class="comment-form-service">
		<div class="comment-form-posting-as-cancel"><a href="javascript:HighlanderComments.cancelExternalWindow();">Cancel</a></div>
		<p>Connecting to %s</p>
	</div>
	
	
</div>


<div id="comment-form-subscribe"> 
	<p class="comment-subscription-form"><input type="checkbox" name="subscribe" id="subscribe" value="subscribe" style="width: auto;" tabindex="6" checked='checked'/> <label class="subscribe-label" id="subscribe-label" for="subscribe">Notify me of follow-up comments via email.</label></p><script type="text/javascript" charset="utf-8">if ( document.cookie.indexOf( 'opt-out-comm-sub-477305=1' ) > -1 ) document.getElementById( 'subscribe' ).checked = false; </script></div>

<script type="text/javascript">
jQuery(document).ready(function(){
	// Expando Mode: start small, then auto-resize on first click + text length
	jQuery( '#comment-form-identity' ).hide();
	jQuery( '#comment-form-subscribe' ).hide();
	jQuery( '#commentform .form-submit' ).hide();
	jQuery( '#comment' ).css( { 'height':'10px' } ).one( 'focus', function() {
		jQuery( this ).animate( { 'height':'70px' } );
		jQuery( '#comment-form-identity' ).slideDown();
		jQuery( '#comment-form-subscribe' ).slideDown();
		jQuery( '#commentform .form-submit' ).slideDown();
	});
});
</script>
												<p class="form-submit">
							<input name="submit" type="submit" id="comment-submit" value="Post Comment" />
							<input type='hidden' name='comment_post_ID' value='277' id='comment_post_ID' />
<input type='hidden' name='comment_parent' id='comment_parent' value='0' />
						</p>
						
<input type="hidden" name="genseq" value="1337099719" />
<p style="display: none;"><input type="hidden" id="akismet_comment_nonce" name="akismet_comment_nonce" value="1b47a7766a" /></p><script type='text/javascript' src='http://s0.wp.com/wp-content/mu-plugins/akismet-2.5/form.js?m=1308783962g&#038;ver=1'></script>
<p style="display: none;"><input type="hidden" id="ak_js" name="ak_js" value="2"/></p>					</form>
							</div><!-- #respond -->
			<div style="clear: both"></div>			
		
	
</div><!-- /comment-template -->

			
			
	</div><!-- /left -->

	<div id="right">
		<ul>
<li id="wp_tag_cloud" class="widget wp_widget_tag_cloud"><h2 class="widgettitle">Tag Cloud</h2>
<div style="overflow:hidden"><a href='http://codemate.wordpress.com/tag/alan-kay/' class='tag-link-2095764' title='1 topic' style='font-size: 8pt;'>Alan Kay</a>
<a href='http://codemate.wordpress.com/tag/architecture/' class='tag-link-2290' title='1 topic' style='font-size: 8pt;'>architecture</a>
<a href='http://codemate.wordpress.com/tag/assertions/' class='tag-link-157723' title='1 topic' style='font-size: 8pt;'>assertions</a>
<a href='http://codemate.wordpress.com/tag/beautiful-code/' class='tag-link-2154673' title='2 topics' style='font-size: 11.405405405405pt;'>beautiful code</a>
<a href='http://codemate.wordpress.com/tag/books/' class='tag-link-178' title='10 topics' style='font-size: 22pt;'>Books</a>
<a href='http://codemate.wordpress.com/tag/bugs-debugging-select/' class='tag-link-5585102' title='1 topic' style='font-size: 8pt;'>bugs debugging select</a>
<a href='http://codemate.wordpress.com/tag/cheat-sheet/' class='tag-link-57214' title='2 topics' style='font-size: 11.405405405405pt;'>cheat sheet</a>
<a href='http://codemate.wordpress.com/tag/code/' class='tag-link-656' title='1 topic' style='font-size: 8pt;'>code</a>
<a href='http://codemate.wordpress.com/tag/combinatorics/' class='tag-link-312353' title='1 topic' style='font-size: 8pt;'>combinatorics</a>
<a href='http://codemate.wordpress.com/tag/database/' class='tag-link-475' title='2 topics' style='font-size: 11.405405405405pt;'>database</a>
<a href='http://codemate.wordpress.com/tag/database-testing/' class='tag-link-2137975' title='3 topics' style='font-size: 13.675675675676pt;'>database testing</a>
<a href='http://codemate.wordpress.com/tag/dbassert/' class='tag-link-7157437' title='3 topics' style='font-size: 13.675675675676pt;'>DbAssert</a>
<a href='http://codemate.wordpress.com/tag/dbunit/' class='tag-link-1511371' title='3 topics' style='font-size: 13.675675675676pt;'>dbunit</a>
<a href='http://codemate.wordpress.com/tag/deadline/' class='tag-link-225447' title='7 topics' style='font-size: 19.351351351351pt;'>deadline</a>
<a href='http://codemate.wordpress.com/tag/demarco/' class='tag-link-1959033' title='7 topics' style='font-size: 19.351351351351pt;'>DeMarco</a>
<a href='http://codemate.wordpress.com/tag/dtd/' class='tag-link-326021' title='1 topic' style='font-size: 8pt;'>DTD</a>
<a href='http://codemate.wordpress.com/tag/emacs/' class='tag-link-11362' title='3 topics' style='font-size: 13.675675675676pt;'>emacs</a>
<a href='http://codemate.wordpress.com/tag/essays/' class='tag-link-786' title='1 topic' style='font-size: 8pt;'>essays</a>
<a href='http://codemate.wordpress.com/tag/git/' class='tag-link-209196' title='2 topics' style='font-size: 11.405405405405pt;'>git</a>
<a href='http://codemate.wordpress.com/tag/iphonedev/' class='tag-link-10969920' title='2 topics' style='font-size: 11.405405405405pt;'>iphonedev</a>
<a href='http://codemate.wordpress.com/tag/java/' class='tag-link-1017' title='10 topics' style='font-size: 22pt;'>Java</a>
<a href='http://codemate.wordpress.com/tag/javascript/' class='tag-link-457' title='1 topic' style='font-size: 8pt;'>javascript</a>
<a href='http://codemate.wordpress.com/tag/junit/' class='tag-link-102270' title='4 topics' style='font-size: 15.567567567568pt;'>jUnit</a>
<a href='http://codemate.wordpress.com/tag/library/' class='tag-link-2624' title='2 topics' style='font-size: 11.405405405405pt;'>library</a>
<a href='http://codemate.wordpress.com/tag/lisp/' class='tag-link-11457' title='2 topics' style='font-size: 11.405405405405pt;'>lisp</a>
<a href='http://codemate.wordpress.com/tag/mac/' class='tag-link-808' title='2 topics' style='font-size: 11.405405405405pt;'>Mac</a>
<a href='http://codemate.wordpress.com/tag/management/' class='tag-link-4236' title='7 topics' style='font-size: 19.351351351351pt;'>Management</a>
<a href='http://codemate.wordpress.com/tag/motivation/' class='tag-link-2885' title='1 topic' style='font-size: 8pt;'>motivation</a>
<a href='http://codemate.wordpress.com/tag/open-source/' class='tag-link-25' title='1 topic' style='font-size: 8pt;'>Open source</a>
<a href='http://codemate.wordpress.com/tag/principles/' class='tag-link-1207' title='1 topic' style='font-size: 8pt;'>principles</a>
<a href='http://codemate.wordpress.com/tag/programming/' class='tag-link-196' title='7 topics' style='font-size: 19.351351351351pt;'>programming</a>
<a href='http://codemate.wordpress.com/tag/puzzle/' class='tag-link-473' title='2 topics' style='font-size: 11.405405405405pt;'>puzzle</a>
<a href='http://codemate.wordpress.com/tag/reflection/' class='tag-link-8408' title='1 topic' style='font-size: 8pt;'>reflection</a>
<a href='http://codemate.wordpress.com/tag/relax-ng/' class='tag-link-749445' title='1 topic' style='font-size: 8pt;'>RELAX NG</a>
<a href='http://codemate.wordpress.com/tag/schematron/' class='tag-link-480525' title='1 topic' style='font-size: 8pt;'>Schematron</a>
<a href='http://codemate.wordpress.com/tag/sql/' class='tag-link-10346' title='2 topics' style='font-size: 11.405405405405pt;'>sql</a>
<a href='http://codemate.wordpress.com/tag/squeak/' class='tag-link-317623' title='1 topic' style='font-size: 8pt;'>Squeak</a>
<a href='http://codemate.wordpress.com/tag/testing/' class='tag-link-12' title='5 topics' style='font-size: 17.081081081081pt;'>testing</a>
<a href='http://codemate.wordpress.com/tag/tools/' class='tag-link-1981' title='1 topic' style='font-size: 8pt;'>tools</a>
<a href='http://codemate.wordpress.com/tag/utils/' class='tag-link-122365' title='1 topic' style='font-size: 8pt;'>utils</a>
<a href='http://codemate.wordpress.com/tag/vi/' class='tag-link-89048' title='3 topics' style='font-size: 13.675675675676pt;'>vi</a>
<a href='http://codemate.wordpress.com/tag/vim/' class='tag-link-18060' title='3 topics' style='font-size: 13.675675675676pt;'>vim</a>
<a href='http://codemate.wordpress.com/tag/windows/' class='tag-link-800' title='1 topic' style='font-size: 8pt;'>Windows</a>
<a href='http://codemate.wordpress.com/tag/xml/' class='tag-link-6852' title='4 topics' style='font-size: 15.567567567568pt;'>XML</a>
<a href='http://codemate.wordpress.com/tag/xml-schema/' class='tag-link-265162' title='1 topic' style='font-size: 8pt;'>Xml Schema</a></div></li>
<li id="rss-189106071" class="widget widget_rss"><h2 class="widgettitle"><a class='rsswidget' href='http://pipes.yahoo.com/pipes/pipe.run?_id=FN9UR_Zj3RGrfPMJw0muhA&#038;_render=rss' title='Syndicate this content'><img style='background:orange;color:white;border:none;' width='14' height='14' src='http://s.wordpress.com/wp-includes/images/rss.png?m=1144196147g' alt='RSS' /></a> <a class='rsswidget' href='http://pipes.yahoo.com/pipes/pipe.info?_id=FN9UR_Zj3RGrfPMJw0muhA' title='Pipes Output'>We read</a></h2>
<ul><li><a class='rsswidget' href='http://www.doubleencore.com/community/' title=''>Double Encore ® - Community -- The High Performance Mobile Company</a></li><li><a class='rsswidget' href='http://longweekendmobile.com/2011/09/07/objc-automatic-reference-counting-in-xcode-explained/' title=''>Understanding Automatic Reference Counting in Objective-C | Long Weekend - iPhone &amp; iPad Apps You&#039;ll Love!</a></li><li><a class='rsswidget' href='http://download.oracle.com/javase/7/docs/webnotes/tsg/TSG-VM/html/crashes.html' title=''>Troubleshooting System Crashes - Troubleshooting Guide for HotSpot VM</a></li><li><a class='rsswidget' href='https://bitbucket.org/sjl/dotfiles/src/tip/vim/.vimrc' title=''>sjl / dotfiles / source — Bitbucket</a></li><li><a class='rsswidget' href='http://rox-xmlrpc.sourceforge.net/niotut/#The_server' title='ServerSocketChannel.open'>Java NIO Tutorial</a></li><li><a class='rsswidget' href='http://idiot.fm/2011/10/25/bez-buldyrabyz/' title=' Tweet'>Без булдырабыз</a></li><li><a class='rsswidget' href='http://www.norvig.com/sudoku.html' title=''>Solving Every Sudoku Puzzle</a></li><li><a class='rsswidget' href='http://feedproxy.google.com/~r/typepad/sethsmainblog/~3/BUyIqXFolI8/what-to-do-next.html' title='This is the most important decision in your career (or even your day). It didn&#039;t used to be. What next used to be a question answered by your boss or your clients. With so many opportunities and so many constraints, successfully picking what to do next is your moment of highest leverage. It deserves more time and attention than most people give it. If y [&hellip;]'>What to do next</a></li><li><a class='rsswidget' href='http://www.bbc.co.uk/go/rss/int/news/-/news/world-europe-15137948' title=''>Denmark introduces food fat tax</a></li><li><a class='rsswidget' href='http://idiot.fm/2011/10/01/simvol-rossii-epoxi-modernizacii/' title='Он гениален, ибо он идеален: НАДУВНАЯ БЕЙСБОЛЬНАЯ БИТА ЦВЕТА РОССИЙСКОГО ФЛАГА С НАДПИСЬЮ «РОССИЯ ВПЕРЕД!» Именно БЕЙСБОЛЬНАЯ бита. Именно цвета российского флага. Именно «Россия вперед!» И именно что НАДУВНАЯ. Блядь, я стоял там, в зоопарке, перед этим прилавком и охуевал. Это же надо было придумать! Наверняка создавший это сам так и не понял, ЧТО он создал [&hellip;]'>Символ России Эпохи Модернизации</a></li></ul></li>
</ul>	</div><!-- /right -->

</div><!-- /page -->

<div id="footer">
	<p class="floatleft"><a href="http://wordpress.com/?ref=footer" rel="generator">Blog at WordPress.com</a>.</p>
	<p class="floatright">Theme: <a href="http://theme.wordpress.com/themes/neutra/" title="Learn more about this theme">Neutra</a> by <a href="http://www.artmov.com/blog/246/neutra-theme-for-wordpress/" rel="designer">Artmov</a>.</p>
</div><!-- /footer -->
</div><!-- /container -->

<script type='text/javascript' src='http://s.gravatar.com/js/gprofiles.js?aa&#038;ver=3.4-beta4-20792'></script>
<script type='text/javascript'>
/* <![CDATA[ */
var WPGroHo = {"my_hash":""};
/* ]]> */
</script>
<script type='text/javascript' src='http://s0.wp.com/wp-content/mu-plugins/gravatar-hovercards/wpgroho.js?m=1318621548g&#038;ver=3.4-beta4-20792'></script>

<script type="text/javascript">
var _qevents = _qevents || [], wpcomQuantcastData = {"qacct":"p-18-mFEk4J448M","labels":",language.en,type.wpcom,posttag.antlr,posttag.grammar,posttag.java,posttag.javacc,posttag.parser,posttag.parsing,posttag.sql"};
function wpcomQuantcastPixel( labels, options ) {
	var i, defaults = wpcomQuantcastData, data = { event: 'ajax' };

	labels  = labels  || '';
	options = options || {};

	if ( typeof labels != 'string' )
		options = labels;

	for ( i in defaults ) {
		data[i] = defaults[i];
	}

	for ( i in options ) {
		data[i] = options[i];
	}

	if ( data.labels ) {
		data.labels += ',' + labels;
	} else {
		data.labels = labels;
	}

	_qevents.push( data );
};
(function() {var elem = document.createElement('script');elem.src = (document.location.protocol == "https:" ? "https://secure" : "http://edge") + ".quantserve.com/quant.js";elem.async = true;elem.type = "text/javascript";var scpt = document.getElementsByTagName('script')[0];scpt.parentNode.insertBefore(elem, scpt);  })();
_qevents.push( wpcomQuantcastData );
</script>
<noscript><div style="display: none;"><img src="//pixel.quantserve.com/pixel/p-18-mFEk4J448M.gif?labels=%2Clanguage.en%2Ctype.wpcom%2Cposttag.antlr%2Cposttag.grammar%2Cposttag.java%2Cposttag.javacc%2Cposttag.parser%2Cposttag.parsing%2Cposttag.sql" height="1" width="1" alt="" /></div></noscript>


	<script type="text/javascript">
	/* <![CDATA[ */
	(function($){
		$(document).on( 'ready post-load', function() {

			// Remove the login box when clicking the page
			$( document ).mousedown( function( e ) {
				if ( null == $( e.target ).closest( '#wpl-mustlogin' ).get( 0 ) ) {
					$( '#wpl-mustlogin' ).remove();
				}
			});

			// Handle clicking the like button itself
			$('.wpl-button > a.like').click( function(e) {
				e.preventDefault();

				var postid = $(this).parent().attr('id').split('like-')[1];
				$.post( 'http://codemate.wordpress.com/wp-admin/admin-ajax.php', {
					'action': 'wpl_record_stat',
					'stat_name': 'loggedout_like_click'
				} );

				var tenMins = new Date();
				tenMins.setTime( tenMins.getTime() + 600000 );
				document.cookie = 'wpl_rand=6a5a62a1d8; expires=' + tenMins.toGMTString() + '; domain=wordpress.com; path=/;';

				$(this).parent().siblings('.wpl-count').after( '\
					<div id="wpl-mustlogin"> \
						<form action="https://codemate.wordpress.com/wp-login.php" method="post"> \
							<p>Just one more step to like this:</p> \
							<label><span>Username</span> <input type="text" name="log" id="user_login" class="input" value="" size="20" tabindex="80" /></label> \
							<label><span>Password</span> <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="81" /></label> \
							<input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="Log In" tabindex="82" /> \
							<input type="hidden" name="postid" value="' + postid + '" /> \
							<input type="hidden" name="redirect_to" value="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser?year=2009&monthnum=02&day=06&name=writing-a-sql-parser&like=1" /> \
							<input type="hidden" name="wpl_rand" value="6a5a62a1d8" /> \
							<p>Not a member yet? <a href="http://wordpress.com/signup/?ref=likebox" id="wpl-signup-link">Sign up with WordPress.com</a></p> \
						</form> \
					</div> \
				');

				$('#wpl-mustlogin').hide().slideDown('fast');
			} );

			$('#wpl-mustlogin input.input').live( 'focus', function() {
				$(this).prev().hide();
			}).live( 'blur', function() {
				if ( $(this).val() == '' ) {
					$(this).prev().show();
				}
			});

			$('#wpl-mustlogin input#wp-submit').live( 'click', function(e) {
				e.preventDefault();

				$.post( 'http://codemate.wordpress.com/wp-admin/admin-ajax.php', {
					'action': 'wpl_record_stat',
					'stat_name': 'loggedout_login_submit'
				}, function() {
					$('#wpl-mustlogin form').submit();
				} );
			});

			$('#wpl-mustlogin a#wpl-signup-link').live( 'click', function(e) {
				e.preventDefault();

				var link = $(this).attr('href');

				$.post( 'http://codemate.wordpress.com/wp-admin/admin-ajax.php', {
					'action': 'wpl_record_stat',
					'stat_name': 'loggedout_signup_click'
				}, function() {
					location.href = link;
				} );
			});
		})
	})(jQuery);
	/* ]]> */
	</script>
<script>jQuery(document).ready(function($){ Gravatar.profile_cb = function( h, d ) { WPGroHo.syncProfileData( h, d );	}; Gravatar.my_hash = WPGroHo.my_hash; Gravatar.init( 'body', '#wp-admin-bar-my-account' ); });</script>	<div style="display:none">
	<div class="grofile-hash-map-9c8f6a36ad787da54bb9e99195e1fab8">
	</div>
	<div class="grofile-hash-map-f927bbed86e344d3d97ed4d5f6a926c9">
	</div>
	<div class="grofile-hash-map-ea0662af98f5642193079ebbb7e78fd5">
	</div>
	<div class="grofile-hash-map-61cf72aee608a6971a5cea5cb8332185">
	</div>
	<div class="grofile-hash-map-f927bbed86e344d3d97ed4d5f6a926c9">
	</div>
	<div class="grofile-hash-map-9b0d8c2175534099cf4f31bcff0106f7">
	</div>
	<div class="grofile-hash-map-d3d1e4aa79ac680843ba722123558748">
	</div>
	<div class="grofile-hash-map-d1f1b733c6a24d56606e7ac535e27545">
	</div>
	</div>
		<style type="text/css">
			
				.reblog-from img                   { margin: 0 10px 0 0; vertical-align: middle; padding: 0; border: 0; }
				.reblogger-note img.avatar         { float: left; padding: 0; border: 0; }
				.reblogger-note-content            { margin: 0 0 20px 35px; }
				.reblog-post                       { border-left: 3px solid #eee; padding-left: 15px; }
				.reblog-post ul.thumb-list         { display: block; list-style: none; margin: 2px 0; padding: 0; clear: both; }
				.reblog-post ul.thumb-list li      { display: inline; margin: 0; padding: 0 1px; border: 0; }
				.reblog-post ul.thumb-list li a    { margin: 0; padding: 0; border: 0; }
				.reblog-post ul.thumb-list li img  { margin: 0; padding: 0; border: 0; }
				.reblog-post                       { border-left: 3px solid #eee; padding-left: 15px; }

				.reblog-post .wpcom-enhanced-excerpt { clear: both; }

				.reblog-post .wpcom-enhanced-excerpt address,
				.reblog-post .wpcom-enhanced-excerpt li,
				.reblog-post .wpcom-enhanced-excerpt h1,
				.reblog-post .wpcom-enhanced-excerpt h2,
				.reblog-post .wpcom-enhanced-excerpt h3,
				.reblog-post .wpcom-enhanced-excerpt h4,
				.reblog-post .wpcom-enhanced-excerpt h5,
				.reblog-post .wpcom-enhanced-excerpt h6,
				.reblog-post .wpcom-enhanced-excerpt p { font-size: 100% !important; }

				.reblog-post .wpcom-enhanced-excerpt blockquote,
				.reblog-post .wpcom-enhanced-excerpt pre,
				.reblog-post .wpcom-enhanced-excerpt code,
				.reblog-post .wpcom-enhanced-excerpt q { font-size: 98% !important; }
					</style><script type='text/javascript'>
/* <![CDATA[ */
var HighlanderComments = {"loggingInText":"Logging In\u2026","submittingText":"Posting Comment\u2026","postCommentText":"Post Comment","connectingToText":"Connecting to %s","commentingAsText":"%1$s: You are commenting using your %2$s account.","logoutText":"Log Out","loginText":"Log In","connectURL":"http:\/\/codemate.wordpress.com\/public.api\/connect\/?action=request","logoutURL":"http:\/\/codemate.wordpress.com\/wp-login.php?action=logout&_wpnonce=303922dccc","homeURL":"http:\/\/codemate.wordpress.com\/","postID":"277","gravDefault":"identicon","enterACommentError":"Please enter a comment","enterEmailError":"Please enter your email address here","invalidEmailError":"Invalid email address","enterAuthorError":"Please enter your name here","gravatarFromEmail":"This picture will show whenever you leave a comment. Click to customize it.","logInToExternalAccount":"Log in to use details from one of these accounts.","change":"Change","changeAccount":"Change Account","comment_registration":"","userIsLoggedIn":""};
/* ]]> */
</script>
<script type='text/javascript' src='http://s1.wp.com/wp-content/mu-plugins/highlander-comments/script.js?m=1334861972g&#038;ver=20110804'></script>
	
	<div id="bit" class="loggedout-follow-normal">
		<a class="bsub" href="javascript:void(0)"><span id='bsub-text'>Follow</span></a>
		<div id="bitsubscribe">
			
					<h3><label for="loggedout-follow-field">Follow &ldquo;Codemate&rdquo;</label></h3>
		
			<form action="https://subscribe.wordpress.com" method="post" accept-charset="utf-8" id="loggedout-follow">
			<p>Get every new post delivered to your Inbox.</p>
			
			<p id="loggedout-follow-error" style="display: none;"></p>

					
			
			<p><input type="text" name="email" style="width: 95%; padding: 1px 2px" value="Enter your email address" onfocus='this.value=(this.value=="Enter your email address") ? "" : this.value;' onblur='this.value=(this.value=="") ? "Enter email address" : this.value;'  id="loggedout-follow-field"/></p>

			<input type="hidden" name="action" value="subscribe"/>
			<input type="hidden" name="blog_id" value="477305"/>
			<input type="hidden" name="source" value="http://codemate.wordpress.com/2009/02/06/writing-a-sql-parser/"/>
			<input type="hidden" name="sub-type" value="loggedout-follow"/>

			<input type="hidden" id="_wpnonce" name="_wpnonce" value="2bb8851fb3" /><input type="hidden" name="_wp_http_referer" value="/2009/02/06/writing-a-sql-parser/" />
			<p id='bsub-subscribe-button'><input type="submit" value="Sign me up" /></p>
			</form>
					<div id='bsub-credit'><a href="http://wordpress.com/signup/?ref=lof">Powered by WordPress.com</a></div>
		</div><!-- #bitsubscribe -->
	</div><!-- #bit -->
<script type="text/javascript" src="http://b.scorecardresearch.com/beacon.js"></script><script type="text/javascript">try{COMSCORE.beacon({c1:2,c2:7518284});}catch(e){}</script><noscript><p class="robots-nocontent"><img src="http://b.scorecardresearch.com/p?cj=1c1=2&#038;c2=7518284" alt="" style="display:none" width="1" height="1" /></p></noscript><script type='text/javascript' src='http://s1.wp.com/wp-content/plugins/syntaxhighlighter/syntaxhighlighter/scripts/shCore.js?m=1258143671g&#038;ver=2.1.364b'></script>
<script type='text/javascript' src='http://s1.wp.com/wp-content/plugins/syntaxhighlighter/syntaxhighlighter/scripts/shBrushSql.js?m=1258143671g&#038;ver=2.1.364b'></script>
<script type='text/javascript' src='http://s0.wp.com/wp-content/plugins/syntaxhighlighter/syntaxhighlighter/scripts/shBrushJava.js?m=1258143671g&#038;ver=2.1.364b'></script>
<script type='text/javascript'>
	(function(){
		var corecss = document.createElement('link');
		var themecss = document.createElement('link');
		var themecssurl = "http://s0.wp.com/wp-content/plugins/syntaxhighlighter-wpcom/shThemeDefault.css?m=1267535107g&amp;ver=2.1.364b";
		if ( themecss.setAttribute ) {
				themecss.setAttribute( "rel", "stylesheet" );
				themecss.setAttribute( "type", "text/css" );
				themecss.setAttribute( "href", themecssurl );
		} else {
				themecss.rel = "stylesheet";
				themecss.href = themecssurl;
		}
		document.getElementsByTagName("head")[0].appendChild(themecss);
	})();
	SyntaxHighlighter.config.clipboardSwf = 'http://s2.wp.com/wp-content/plugins/syntaxhighlighter/syntaxhighlighter/scripts/clipboard.swf?m=1303162058g';
	SyntaxHighlighter.config.strings.expandSource = 'show source';
	SyntaxHighlighter.config.strings.viewSource = 'view source';
	SyntaxHighlighter.config.strings.copyToClipboard = 'copy to clipboard';
	SyntaxHighlighter.config.strings.copyToClipboardConfirmation = 'The code is in your clipboard now';
	SyntaxHighlighter.config.strings.print = 'print';
	SyntaxHighlighter.config.strings.help = '?';
	SyntaxHighlighter.config.strings.alert = 'SyntaxHighlighter\n\n';
	SyntaxHighlighter.config.strings.noBrush = 'Can\'t find brush for: ';
	SyntaxHighlighter.config.strings.brushNotHtmlScript = 'Brush wasn\'t configured for html-script option: ';
	SyntaxHighlighter.all();
</script>
<script type="text/javascript">
// <![CDATA[
(function() {
try{
  if ( window.external &&'msIsSiteMode' in window.external) {
    if (window.external.msIsSiteMode()) {
      var jl = document.createElement('script');
      jl.type='text/javascript';
      jl.async=true;
      jl.src='/wp-content/plugins/ie-sitemode/custom-jumplist.php';
      var s = document.getElementsByTagName('script')[0];
      s.parentNode.insertBefore(jl, s);
    }
  }
}catch(e){}
})();
// ]]>
</script><script src="http://s.stats.wordpress.com/w.js?21" type="text/javascript"></script>
<script type="text/javascript">
st_go({'blog':'477305','v':'wpcom','user_id':'0','post':'277','subd':'codemate'});
ex_go({'crypt':'UE40eW5QN0p8M2Y/RE1oOHBqWkJdYy5wL35xRnR4SVtWLmluVHQrZ3JBRDNRaV9yeU4rX041RXBzU1FiayxfJjYsMDgtdFZmQnZkfkQ1amVEcnJlejFUb05YRWwxWXJIUUpFRmcmeE5BMjA5WDlwNC03ZExvNElYP3N6TnwlbCs9XXNmSHp8Vzh8ZVtRM2pOVDdILC9senxNWHBndVhUOGRJSFE9NEZIVy9KZVpoND1CWkUlaTFWTi58fD1yRGE/ZUpRdm5TJXNGcWt+YS9oSzFRa0cwMGowJjh5RjZSNT1Ld0llakxSOTUtN3RvfCsmJXJKcE9CPThfdF1+W2ZlMTdVZEp4YX4zL3J4XVRRTVBiOXRlMw=='});
addLoadEvent(function(){linktracker_init('477305',277);});
	</script>
<noscript><img src="http://stats.wordpress.com/b.gif?v=noscript" style="height:0px;width:0px;overflow:hidden" alt="" /></noscript>
</body>
</html>